(function(){
	window.onload=function(){
		/*金额小于100的时候按钮变灰*/
		var money=$("#qian"),
			trs=$("#tab1 tbody tr"),
			b=0,
			zongji=$("#tab1 tfoot tr:nth-child(2)"),
			ben_tixian=$("#tixian");
		var cur_money=parseInt(money.text());
		if(cur_money<100){
			ben_tixian.css("opacity",".2");
			ben_tixian.attr("disabled");
		}
	}
	var trs=$("#tab1 tbody tr"),
			b=0,
			c=0,
			ben_tixian=$("#tixian"),
			zongji=$("#tab1 tfoot tr td:nth-child(2)"),
			zongji2=$("#tab1 tfoot tr td:nth-child(3)");
		/****循环计算table里面的合计问题****/
		for(var i=0;i<trs.length;i++){
			var a=parseFloat(trs.eq(i).children(":nth-child(2)").text());
			b=b+a;//得到第二个合计的值
			var d=parseFloat(trs.eq(i).children(":nth-child(3)").text());
			c=c+d;//得到第三个合计的值
		}
		zongji.text(b);
		zongji2.text(c);
		/***统计总共有多少条记录***/
		var jilu=$("#tab2 tbody tr"),
			fenyezongji=$("#fenyezongji");
			fenyezongji.text(jilu.length);
	/***收起****/
	var anniu=$("#shouqi"),
		shouqidiv=$("#sq");
	anniu.on("click",function(){
		shouqidiv.toggleClass("shouqi");
	})
	/**提现申请**/
	var tixianshengqing =$("#tixianshengqing"),
		bangding=$("#cwxx");
	tixianshengqing.on("click",function(){
		bangding.css("display","block");
		ben_tixian.css("opacity",".2");
		ben_tixian.attr("disabled","disabled");
	})
	var zhezhao=$(".tixian_mask");
	ben_tixian.on("click",function(){
		zhezhao.css("display","block");
	})
	
	/***提现弹窗****/
	var tixianqian =$("#tixianqian"),
		wenben=$("#wenben"),
		o5_dele=$("#o5_dele"),
		o5_ok=$("#o5_ok"),
		tishi=$("#tishi");
		tixian_mask=$(".tixian_mask");
	o5_dele.on("click",function(){
		tixian_mask.css("display","none");
	})
	/*获取input的值*/
	wenben.on("blur",function(){
		var wenben_val=wenben.val();
		var shurujine=parseFloat(tixianqian.text());
		if(isNaN(parseFloat(wenben_val))){
			tishi.text("请输入正确金额");
			tishi.css("opacity","1");
		}else if(parseInt(parseFloat(wenben_val))<100){
			tishi.text("提现金额不少于100元");
			tishi.css("opacity","1");
		}else if(parseFloat(wenben_val)>parseFloat(tixianqian.text())){
			tishi.text("提现金额不得超过可提金额");
			tishi.css("opacity","1");
		}else{
			o5_ok.on("click",function(){
				tixian_mask.css("display","none");
			})
		}
	})
})();
